﻿Public Class CapNhatThongTinKH_DAO
    Public Shared Function SelectAll() As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from KhachHang"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Function SelectByKhachHang(_kh As CapNhatThongTinKH_DTO) As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from KhachHang where TenCTY like '%" & _kh.TenCTY & "%'"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
  
    Public Shared Sub Insert(_kh As CapNhatThongTinKH_DTO)
        Dim strSQL As String = "Insert into KhachHang(MaCTY,TenCTY,DiaChi,SoDT,SoFax) values('" & _kh.MaCTY & "','" & _kh.TenCTY & "','" & _kh.DiaChi & "'," & _kh.SoDT & "," & _kh.SoFax & " )"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Sub Delete(_kh As CapNhatThongTinKH_DTO)
        Dim strSQL As String = "Delete from KhachHang where MaCTY ='" & _kh.MaCTY & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub

    Public Shared Sub Update(_kh As CapNhatThongTinKH_DTO)
        Dim strSQL As String = "Update KhachHang set MaCTY='" & _kh.MaCTY & "' ,TenCTY='" & _kh.TenCTY & "' ,DiaChi='" & _kh.DiaChi & "',SoDT=" & _kh.SoDT & ",SoFax=" & _kh.SoFax & "  where MaCTY = '" & _kh.MaCTY & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
End Class
